'''
Created on Jul 14, 2012

@author: catapult
'''

import pygame
import csv
import pokemon
import random
import player
import textBox
import gui

tbox='blank'

movedex  = []
typedex  = []

data = csv.reader(open('..\\data\\moves.csv'), delimiter = ',', quotechar = '/')
types = csv.reader(open('..\\data\\type_efficacy.csv'), delimiter = ',', quotechar = '/')
for row in data:
    movedex.append(row)
    print ('loading ' + movedex[-1][0] + '-' +movedex[-1][1])
for row in types:
    typedex.append(row)

class Move:
    def __init__(self, move_ID):
            
        self.ID = move_ID
        self.damage=0
        self.name()
        self.type()
        self.power()
        self.pp()
        self.accuracy()
        self.priority()
        self.damage_type()
        self.category()
        self.effect_ID()
        self.effect_percentage()
        self.recoil()
        self.healing()
        self.crit_rate()
        self.flinch_rate()
        self.stat_rate()
        self.min_hits()
        self.max_hits()
        self.min_turns()
        self.max_turns()
        self.PP_check()

    def name (self):
        self.name = movedex[self.ID][1]
        return self.name
    
    def type (self):
        self.type = int(movedex[self.ID][2])
        return self.type
        
    def power (self):
        self.power = int(movedex[self.ID][3])
        return self.power
    
    def pp (self):
        pp = int(movedex[self.ID][4])
        self.pp = [pp, pp]
        return self.pp
        
    def accuracy (self):
        self.accuracy = int(movedex[self.ID][5])
        return self.accuracy
    
    def priority (self):
        self.priority = int(movedex[self.ID][6])
        return self.priority
    
    def damage_type (self):
        self.damage_type = movedex[self.ID][7]
        return self.damage_type
    
    def category (self):
        self.category = movedex[self.ID][8]
        return self.category
    
    def effect_ID (self):
        self.effect_ID = int(movedex[self.ID][9])
        return self.effect_ID
    
    def effect_percentage (self):
        self.effect_percentage = int(movedex[self.ID][10])
        return self.effect_percentage
        
    def recoil (self):
        self.recoil = float(movedex[self.ID][11])
        return self.recoil
    
    def healing (self):
        self.healing = float(movedex[self.ID][12])
        return self.healing
    
    def crit_rate (self):
        self.crit_rate = int(movedex[self.ID][13])
        return self.crit_rate
        
    def flinch_rate (self):
        self.flinch_rate = int(movedex[self.ID][14])
        return self.flinch_rate
    
    def stat_rate (self):
        self.stat_rate = int(movedex[self.ID][15])
        return self.stat_rate
    
    def min_hits (self):
        self.min_hits = int(movedex[self.ID][16])
        return self.min_hits
    
    def max_hits (self):
        self.max_hits = int(movedex[self.ID][17])
        return self.max_hits
        
    def min_turns (self):
        self.min_turns = int(movedex[self.ID][18])
        return self.min_turns
    
    def max_turns (self):
        self.max_turns = int(movedex[self.ID][19])
        return self.max_turns
    
    def PP_check (self):
        if self.pp[0] <= 0:
            print ('You have no pp you loser')
            return False        
    
    def use (self, user, target):
        self.user = user
        self.target = target
        self.userP=user.pokemon[user.activePoke]
        self.targP=target.pokemon[target.activePoke]
        #check statuses
        print(self.userP.status[-1])
        if self.userP.status[-1] == 'frozen':
            if self.effect_ID == 254:#moves that defrost stuff
                self.userP.status.append['none']
                tbox.addMessage(20, self.userP.name)
                pass
            else:    
                print ('Your pokemon is a block of ice. Blocks of ice can\'t attack')
                tbox.addMessage(30, 'Your pokemon is a block of ice. Blocks of ice can\'t attack')
                return False
        elif self.userP.status[-1] == 'sleep':
            if self.name == 'SNORE' or self.name == 'SLEEP TALK':#moves that can be used while sleeping
                pass
            else:
                tbox.addMessage(17, self.userP.name)
                return False
        elif self.userP.status[-1] == 'paralyz':
            Parahax = random.randrange(0, 4)
            if Parahax == 0:
                tbox.addMessage(16, self.userP.name)
                print ('The pokemon is fully Paralyzed')
                return False
        self.pp[0] -= 1
        #check confusion
        if self.userP.Cstatus[-1] == 'conf':
            tbox.addMessage(31, self.userP.name)
            rand = random.randrange(0,2)
            if rand == 1:
                self.userP.HP_stat[0] -= (1 / 16 * (self.userP.HP_stat[1]))
                tbox.addMessage(13, self.userP.name)
                return False
        accuracy_check = Accuracy().check(self.accuracy)
        #check ACCURACY
        if accuracy_check == False:
            tbox.addMessage(1, self.userP.name)
            return False
        #set STAB
        if self.type == self.userP.type1 or self.type == self.userP.type2:
            self.type_check = 1.5
        else:
            self.type_check = 1
        #set effectiveness
        if self.targP.type2 == 0:
            self.type_check2 = (int(typedex[self.type][self.targP.type1]) / 100)
        else:
            self.type_check2 = ((int(typedex[self.type][self.targP.type1]) / 100) * (int(typedex[self.type][self.targP.type2]) / 100))
        tbox.addMessage(0, self.userP.name, self.name)
        if self.type_check2>1:
            tbox.addMessage(2)
        elif self.type_check2 == 0:
            tbox.addMessage(4)
        elif self.type_check2<1:
            tbox.addMessage(3)
        #calculates damage
        self.do_damage()
        #check CRIT HAX
        randcrit = random.randrange(1,10001)
        if self.damage > 0:    
            if self.crit_rate == 0:
                if randcrit <= 625:
                    self.damage = self.damage*2
                    tbox.addMessage(5)
                else:
                    pass
            elif self.crit_rate == 1:
                if randcrit <= 1250:
                    self.damage = self.damage*2
                    tbox.addMessage(5)
                else:
                    pass
            elif self.crit_rate == 2:
                if randcrit <= 2500:
                    self.damage = self.damage*2
                    tbox.addMessage(5)
                else:
                    pass
            elif self.crit_rate == 3:
                if randcrit <= 3330:
                    self.damage = self.damage*2
                    tbox.addMessage(5)
                else:
                    pass        
            elif self.crit_rate > 3:
                if randcrit <= 5000:
                    self.damage = self.damage*2
                    tbox.addMessage(5)
                else:
                    pass
        #check effect accuracy
        effect_accuracy_check = Accuracy().check(self.effect_percentage)
#########################effect happens############################################################################################
        if effect_accuracy_check == True:
            if self.effect_ID == 1:
                pass
            elif self.effect_ID == 2:
                self.targP.status.append('sleep')
                tbox.addMessage(17, self.targP.name)
                
            elif self.effect_ID == 3:
                self.targP.status.append('poison')
                tbox.addMessage(30, self.targP.name + ' is now poisoned')
                
            elif self.effect_ID == 4:
                self.userP.HP_stat[0] += (self.damage // 2)
                
            elif self.effect_ID == 5:
                self.targP.status.append('burn')
                tbox.addMessage(30, self.targP.name + ' is now burnt.')
                
            elif self.effect_ID == 6:
                self.targP.status.append('frozen')
                tbox.addMessage(30, self.targP.name + ' is now a block of ice.')
                
            elif self.effect_ID == 7:
                self.targP.status.append('paralyz')
                tbox.addMessage(30, self.targP.name + ' is now paralyzed')
                
            elif self.effect_ID == 8:
                self.userP.HP_stat[0] = 0
                
            elif self.effect_ID== 9:
                if self.targP.status[-1] != 'sleep':
                    self.damage=0
                self.userP.HP_stat[0] += (int(self.healing * self.damage))
            
            elif self.effect_ID == 10:
                pass
                
            elif self.effect_ID == 11:
                self.userP.statMod1 += 1
                if self.userP.statMod1 > 6:
                    self.userP.statMod1 = 6
                elif self.userP.statMod1 < -6:
                    self.userP.statMod1 = -6
                if self.userP.statMod1 >= 0:
                    self.userP.attack_stat[0] = int(self.userP.attack_stat[1] * (2 + self.userP.statMod1) / 2)
                    tbox.addMessage(30, self.userP.name + '\'s attack has been raised.')
                elif self.userP.statMod1 <= 0:
                    self.userP.attack_stat[0] = abs(int(self.userP.attack_stat[1] * 2 / (2 + abs(self.userP.statMod1))))
                    tbox.addMessage(30, self.userP.name + '\'s attack has been lowered.')
                
            elif self.effect_ID == 12:
                self.userP.statMod2 += 1
                if self.userP.statMod2 > 6:
                    self.userP.statMod2 = 6
                elif self.userP.statMod2 < -6:
                    self.userP.statMod2 = -6
                if self.userP.statMod2 >= 0:
                    self.userP.defense_stat[0] = int(self.userP.defense_stat[1] * (2 + self.userP.statMod2) / 2)
                    tbox.addMessage(30, self.userP.name + '\'s defense has been raised.')
                elif self.userP.statMod2 <= 0:
                    self.userP.defense_stat[0] = abs(int(self.userP.defense_stat[1] * 2 / (2 + abs(self.userP.statMod2))))
                    tbox.addMessage(30, self.userP.name + '\'s defense has been lowered.')
                
            elif self.effect_ID == 14:
                self.userP.statMod3 += 1
                if self.userP.statMod3 > 6:
                    self.userP.statMod3 = 6
                elif self.userP.statMod3 < -6:
                    self.userP.statMod3 = -6
                if self.userP.statMod3 >= 0:
                    self.userP.SPattack_stat[0] = int(self.userP.SPattack_stat[1] * (2 + self.userP.statMod3) / 2)
                    tbox.addMessage(30, self.userP.name + '\'s Special Attack has been raised.')
                elif self.userP.statMod3 <= 0:
                    self.userP.SPattack_stat[0] = abs(int(self.userP.SPattack_stat[1] * 2 / (2 + abs(self.userP.statMod3))))
                    tbox.addMessage(30, self.userP.name + '\'s Special Attack has been lowered.')
                 
            elif self.effect_ID == 19:
                self.targP.statMod1 -= 1
                if self.targP.statMod1 > 6:
                    self.targP.statMod1 = 6
                elif self.targP.statMod1 < -6:
                    self.targP.statMod1 = -6
                if self.targP.statMod1 >= 0:
                    self.targP.attack_stat[0] = int(self.targP.attack_stat[1] * (2 + self.targP.statMod1) / 2)
                    tbox.addMessage(30, self.targP.name + '\'s Attack has been raised.')
                elif self.targP.statMod1 <= 0:
                    self.targP.attack_stat[0] = abs(int(self.targP.attack_stat[1] * 2 / (2 + abs(self.targP.statMod1))))
                    tbox.addMessage(30, self.targP.name + '\'s Attack has been lowered.')
                
            elif self.effect_ID == 20:
                self.targP.statMod2 -= 1
                if self.targP.statMod2 > 6:
                    self.targP.statMod2 = 6
                elif self.targP.statMod2 < -6:
                    self.targP.statMod2 = -6
                if self.targP.statMod2 >= 0:
                    self.targP.defense_stat[0] = int(self.targP.defense_stat[1] * (2 + self.targP.statMod2) / 2)
                    tbox.addMessage(30, self.targP.name + '\'s Defense has been raised.')
                elif self.targP.statMod2 <= 0:
                    self.targP.defense_stat[0] = abs(int(self.targP.defense_stat[1] * 2 / (2 + abs(self.targP.statMod2))))
                    tbox.addMessage(30, self.targP.name + '\'s Defense has been lowered.')
                 
            elif self.effect_ID == 21:
                self.targP.statMod5 -= 1
                if self.targP.statMod5 > 6:
                    self.targP.statMod5 = 6
                elif self.targP.statMod5 < -6:
                    self.targP.statMod5 = -6
                if self.targP.statMod5 >= 0:
                    self.targP.speed_stat[0] = int(self.targP.speed_stat[1] * (2 + self.targP.statMod5) / 2)
                    tbox.addMessage(30, self.targP.name + '\'s Speed has been raised.')
                elif self.targP.statMod5 <= 0:
                    self.targP.speed_stat[0] = abs(int(self.targP.speed_stat[1] * 2 / (2 + abs(self.targP.statMod5))))
                    tbox.addMessage(30, self.targP.name + '\'s Speed has been lowered.')
            
            elif self.effect_ID == 26:
                self.userP.statMod1=0
                self.userP.statMod2=0
                self.userP.statMod3=0
                self.userP.statMod4=0
                self.userP.statMod5=0
                self.targP.statMod1=0
                self.targP.statMod2=0
                self.targP.statMod3=0
                self.targP.statMod4=0
                self.targP.statMod5=0
            
            elif self.effect_ID == 33:
                self.userP.HP_stat[0]+=(self.userP.HP_stat[1]//2)
                
            elif self.effect_ID == 34:
                self.userP.status.append('bad_poison')
                tbox.addMessage(30, self.targP.name + ' is now poisoned')
            
            elif self.effect_ID == 38:
                self.userP.HP_stat[0]+=(self.userP.HP_stat[1]//2)
                self.userP.status.append('sleep')
                
            elif self.effect_ID == 39:
                self.damage=self.targP.HP_stat[1]
                
            elif self.effect_ID == 49:
                self.userP.HP_stat[0]-=(int(self.recoil*self.damage))
            elif self.effect_ID == 51:
                self.userP.statMod1 += 2
                if self.userP.statMod1 > 6:
                    self.userP.statMod1 = 6
                elif self.userP.statMod1 < -6:
                    self.userP.statMod1 = -6
                if self.userP.statMod1 >= 0:
                    self.userP.attack_stat[0] = int(self.userP.attack_stat[1] * (2 + self.userP.statMod1) / 2)
                    tbox.addMessage(30, self.userP.name + '\'s attack has been raised.')
                elif self.userP.statMod1 <= 0:
                    self.userP.attack_stat[0] = abs(int(self.userP.attack_stat[1] * 2 / (2 + abs(self.userP.statMod1))))
                    tbox.addMessage(30, self.userP.name + '\'s attack has been lowered.')
                
            elif self.effect_ID == 52:
                self.userP.statMod2 += 2
                if self.userP.statMod2 > 6:
                    self.userP.statMod2 = 6
                elif self.userP.statMod2 < -6:
                    self.userP.statMod2 = -6
                if self.userP.statMod2 >= 0:
                    self.userP.defense_stat[0] = int(self.userP.defense_stat[1] * (2 + self.userP.statMod2) / 2)
                    tbox.addMessage(30, self.userP.name + '\'s defense has been raised.')
                elif self.userP.statMod2 <= 0:
                    self.userP.defense_stat[0] = abs(int(self.userP.defense_stat[1] * 2 / (2 + abs(self.userP.statMod2))))
                    tbox.addMessage(30, self.userP.name + '\'s defense has been lowered.')
                
            elif self.effect_ID == 53:
                self.userP.statMod5+=2
                if self.userP.statMod5>6:
                    self.userP.statMod5=6
                elif self.userP.statMod5<-6:
                    self.userP.statMod5=-6
                if self.userP.statMod5>=0:
                    self.userP.speed_stat[0]=int(self.userP.speed_stat[1]*(2+self.userP.statMod5)/2)
                    tbox.addMessage(30, self.userP.name + '\'s Speed has been raised.')
                elif self.userP.statMod5<=0:
                    self.userP.speed_stat[0]=abs(int(self.userP.speed_stat[1]*2/(2+abs(self.userP.statMod5))))
                    tbox.addMessage(30, self.userP.name + '\'s Speed has been lowered.')
                
            elif self.effect_ID == 54:
                self.userP.statMod3+=2
                if self.userP.statMod3>6:
                    self.userP.statMod3=6
                elif self.userP.statMod3<-6:
                    self.userP.statMod3=-6
                if self.userP.statMod3>=0:
                    self.userP.SPattack_stat[0]=int(self.userP.SPattack_stat[1]*(2+self.userP.statMod3)/2)
                    tbox.addMessage(30, self.userP.name + '\'s Special Attack has been raised.')
                elif self.userP.statMod3<=0:
                    self.userP.SPattack_stat[0]=abs(int(self.userP.SPattack_stat[1]*2/(2+abs(self.userP.statMod3))))
                    tbox.addMessage(30, self.userP.name + '\'s Special Attack has been lowered.')
                
            elif self.effect_ID == 55:
                self.userP.statMod4+=2
                if self.userP.statMod4>6:
                    self.userP.statMod4=6
                elif self.userP.statMod4<-6:
                    self.userP.statMod4=-6
                if self.userP.statMod4>=0:
                    self.userP.SPdefense_stat[0]=int(self.userP.SPdefense_stat[1]*(2+self.userP.statMod4)/2)
                    tbox.addMessage(30, self.userP.name + '\'s Special Defense has been raised.')
                elif self.userP.statMod4<=0:
                    self.userP.SPdefense_stat[0]=abs(int(self.userP.SPdefense_stat[1]*2/(2+abs(self.userP.statMod4))))
                    tbox.addMessage(30, self.userP.name + '\'s Special Defense has been lowered.')
                
            elif self.effect_ID == 59:
                self.targP.statMod1-=2
                if self.targP.statMod1>6:
                    self.targP.statMod1=6
                elif self.targP.statMod1<-6:
                    self.targP.statMod1=-6
                if self.targP.statMod1>=0:
                    self.targP.attack_stat[0]=int(self.targP.attack_stat[1]*(2+self.targP.statMod1)//2)
                    tbox.addMessage(30, self.targP.name + '\'s Attack has been raised.')
                elif self.targP.statMod1<=0:
                    self.targP.attack_stat[0]=abs(int(self.targP.attack_stat[1]*2//(2+abs(self.targP.statMod1))))
                    tbox.addMessage(30, self.targP.name + '\'s Attack has been lowered.')
                
            elif self.effect_ID == 60:
                self.targP.statMod2-=2
                if self.targP.statMod2>6:
                    self.targP.statMod2=6
                elif self.targP.statMod2<-6:
                    self.targP.statMod2=-6
                if self.targP.statMod2>=0:
                    self.targP.defense_stat[0]=int(self.targP.defense_stat[1]*(2+self.targP.statMod2)/2)
                    tbox.addMessage(30, self.targP.name + '\'s Defense has been raised.')
                elif self.targP.statMod2<=0:
                    self.targP.defense_stat[0]=abs(int(self.targP.defense_stat[1]*2/(2+abs(self.targP.statMod2))))
                    tbox.addMessage(30, self.targP.name + '\'s Defense has been lowered.')
                
            elif self.effect_ID == 61:
                self.targP.statMod5-=2
                if self.targP.statMod5>6:
                    self.targP.statMod5=6
                elif self.targP.statMod5<-6:
                    self.targP.statMod5=-6
                if self.targP.statMod5>=0:
                    self.targP.speed_stat[0]=int(self.targP.speed_stat[1]*(2+self.targP.statMod5)/2)
                    tbox.addMessage(30, self.targP.name + '\'s Speed has been raised.')
                elif self.targP.statMod5<=0:
                    self.targP.speed_stat[0]=abs(int(self.targP.speed_stat[1]*2/(2+abs(self.targP.statMod5))))
                    tbox.addMessage(30, self.targP.name + '\'s Speed has been lowered.')                                
                
            elif self.effect_ID == 63:
                self.targP.statMod4-=2
                if self.targP.statMod4>6:
                    self.targP.statMod4=6
                elif self.targP.statMod4<-6:
                    self.targP.statMod4=-6
                if self.targP.statMod4>=0:
                    self.targP.SPdefense_stat[0]=int(self.targP.SPdefense_stat[1]*(2+self.targP.statMod4)/2)
                    tbox.addMessage(30, self.targP.name + '\'s Special Defense has been raised.')
                elif self.targP.statMod4<=0:
                    self.targP.SPdefense_stat[0]=abs(int(self.targP.SPdefense_stat[1]*2/(2+abs(self.targP.statMod4))))
                    tbox.addMessage(30, self.targP.name + '\'s Special Defense has been lowered.')
            
            elif self.effect_ID == 67:
                self.targP.status.append('poison')
                tbox.addMessage(30, self.targP.name + ' is now poisoned')
                
            elif self.effect_ID == 68:
                self.targP.status.append('paralyz')
                tbox.addMessage(30, self.targP.name + ' is now paralyzed')
                
            elif self.effect_ID == 69:
                self.targP.statMod1 -= 1
                if self.targP.statMod1 > 6:
                    self.targP.statMod1 = 6
                elif self.targP.statMod1 < -6:
                    self.targP.statMod1 = -6
                if self.targP.statMod1 >= 0:
                    self.targP.attack_stat[0] = int(self.targP.attack_stat[1] * (2 + self.targP.statMod1) / 2)
                    tbox.addMessage(30, self.targP.name + '\'s Attack has been raised.')
                elif self.targP.statMod1 <= 0:
                    self.targP.attack_stat[0] = abs(int(self.targP.attack_stat[1] * 2 / (2 + abs(self.targP.statMod1))))
                    tbox.addMessage(30, self.targP.name + '\'s Attack has been lowered.')
                    
            elif self.effect_ID == 70:
                self.targP.statMod2 -= 1
                if self.targP.statMod2 > 6:
                    self.targP.statMod2 = 6
                elif self.targP.statMod2 < -6:
                    self.targP.statMod2 = -6
                if self.targP.statMod2 >= 0:
                    self.targP.defense_stat[0] = int(self.targP.defense_stat[1] * (2 + self.targP.statMod2) / 2)
                    tbox.addMessage(30, self.targP.name + '\'s Defense has been raised.')
                elif self.targP.statMod2 <= 0:
                    self.targP.defense_stat[0] = abs(int(self.targP.defense_stat[1] * 2 / (2 + abs(self.targP.statMod2))))
                    tbox.addMessage(30, self.targP.name + '\'s Defense has been lowered.')
                    
            elif self.effect_ID == 71:
                self.targP.statMod5-=1
                if self.targP.statMod5>6:
                    self.targP.statMod5=6
                elif self.targP.statMod5<-6:
                    self.targP.statMod5=-6
                if self.targP.statMod5>=0:
                    self.targP.speed_stat[0]=int(self.targP.speed_stat[1]*(2+self.targP.statMod5)/2)
                    tbox.addMessage(30, self.targP.name + '\'s Speed has been raised.')
                elif self.targP.statMod5<=0:
                    self.targP.speed_stat[0]=abs(int(self.targP.speed_stat[1]*2/(2+abs(self.targP.statMod5))))
                    tbox.addMessage(30, self.targP.name + '\'s Speed has been lowered.')
                    
            elif self.effect_ID == 72:
                self.targP.statMod3-=1
                if self.targP.statMod3>6:
                    self.targP.statMod3=6
                elif self.targP.statMod3<-6:
                    self.targP.statMod3=-6
                if self.targP.statMod3>=0:
                    self.targP.SPattack_stat[0]=int(self.targP.SPattack_stat[1]*(2+self.targP.statMod3)/2)
                    tbox.addMessage(30, self.targP.name + '\'s Special Attack has been raised.')
                elif self.targP.statMod1<=0:
                    self.targP.SPattack_stat[0]=abs(int(self.targP.SPattack_stat[1]*2/(2+abs(self.targP.statMod3))))
                    tbox.addMessage(30, self.targP.name + '\'s Special Attack has been lowered.')
            
            elif self.effect_ID == 73:
                self.targP.statMod4-=1
                if self.targP.statMod4>6:
                    self.targP.statMod4=6
                elif self.targP.statMod4<-6:
                    self.targP.statMod4=-6
                if self.targP.statMod4>=0:
                    self.targP.SPdefense_stat[0]=int(self.targP.SPdefense_stat[1]*(2+self.targP.statMod4)/2)
                    tbox.addMessage(30, self.targP.name + '\'s Special Defense has been raised.')
                elif self.targP.statMod4<=0:
                    self.targP.SPdefense_stat[0]=abs(int(self.targP.SPdefense_stat[1]*2/(2+abs(self.targP.statMod4))))
                    tbox.addMessage(30, self.targP.name + '\'s Special Defense has been lowered.')
                    
            elif self.effect_ID == 77:
                self.targP.Cstatus.append('conf')
                tbox.addMessage(30, self.targP.name + ' has become Confused')
                
            elif self.effect_ID == 88:
                self.damage=self.userP.level
                
            elif self.effect_ID == 100:
                HPnum=(64 * self.userP.HP_stat[0]//self.userP.HP_stat[1])
                if 0<=HPnum<=1:
                    self.power=200
                    self.do_damage()
                elif 2<=HPnum<=5:
                    self.power=150
                    self.do_damage()
                elif 6<=HPnum<=12:
                    self.power=100
                    self.do_damage()
                elif 13<=HPnum<=21:
                    self.power=80
                    self.do_damage()
                elif 22<=HPnum<=42:
                    self.power=40
                    self.do_damage
                elif 43<=HPnum<=64:
                    self.power=20
                    self.do_damage()
                
            elif self.effect_ID == 110:
                if self.userP.type1 == 8 or self.userP.type2 == 8:
                    self.userP.HP_stat[0]-=((self.userP.HP_stat[1])//2)
                    self.targP.curse=True
                    tbox.addMessage(30, self.targP.name + 'is now cursed')
                    
                else:
                    print(str(self.userP.attack_stat[0])+','+str(self.userP.defense_stat[0])+','+str(self.userP.speed_stat[0]))
                    self.userP.statMod5 -= 1
                    print (self.userP.statMod5)
                    if self.userP.statMod5 > 6:
                        self.userP.statMod5 = 6
                    elif self.userP.statMod5 < -6:
                        self.userP.statMod5 = -6
                    if self.userP.statMod5 >= 0:
                        self.userP.speed_stat[0] = int(self.userP.speed_stat[1]*(2+self.userP.statMod5)/2)
                        tbox.addMessage(30, self.userP.name + '\'s Speed has been raised.')
                    elif self.userP.statMod5 <= 0:
                        self.userP.speed_stat[0] = abs(int(self.userP.speed_stat[1]*2/(2+abs(self.userP.statMod5)))) 
                        tbox.addMessage(30, self.userP.name + '\'s Speed has been lowered.')
                    self.userP.statMod1 += 1
                    if self.userP.statMod1 > 6:
                        self.userP.statMod1 = 6
                    elif self.userP.statMod1 < -6:
                        self.userP.statMod1 = -6
                    if self.userP.statMod1 >= 0:
                        self.userP.attack_stat[0] = int(self.userP.attack_stat[1] * (2 + self.userP.statMod1) / 2)
                        tbox.addMessage(30, self.userP.name + '\'s attack has been raised.')
                    elif self.userP.statMod1 <= 0:
                        self.userP.attack_stat[0] = abs(int(self.userP.attack_stat[1] * 2 / (2 + abs(self.userP.statMod1))))
                        tbox.addMessage(30, self.userP.name + '\'s attack has been lowered.')
                    self.userP.statMod2 += 1
                    if self.userP.statMod2 > 6:
                        self.userP.statMod2 = 6
                    elif self.userP.statMod2 < -6:
                        self.userP.statMod2 = -6
                    if self.userP.statMod2 >= 0:
                        self.userP.defense_stat[0] = int(self.userP.defense_stat[1] * (2 + self.userP.statMod2) / 2)
                        tbox.addMessage(30, self.userP.name + '\'s defense has been raised.')
                    elif self.userP.statMod2 <= 0:
                        self.userP.defense_stat[0]=abs(int(self.userP.defense_stat[1]*2/(2+abs(self.userP.statMod2))))
                        tbox.addMessage(30, self.userP.name + '\'s defense has been lowered.')
                    
            elif self.effect_ID == 119:
                self.targP.statMod1+=2
                if self.targP.statMod1>6:
                    self.targP.statMod1=6
                elif self.targP.statMod1<-6:
                    self.targP.statMod1=-6
                if self.targP.statMod1>=0:
                    self.targP.attack_stat[0]=int(self.targP.attack_stat[1]*(2+self.targP.statMod1)/2)
                    tbox.addMessage(30, self.targP.name + '\'s Attack has been raised.')
                elif self.targP.statMod1<=0:
                    self.targP.attack_stat[0]=abs(int(self.targP.attack_stat[1]*2/(2+abs(self.targP.statMod1))))
                    tbox.addMessage(30, self.targP.name + '\'s Attack has been lowered.')
                self.targP.status.append('conf')
                tbox.addMessage(11, self.targP.name)
                
            elif self.effect_ID == 152:
                pass
            
            elif self.effect_ID == 153:
                self.targP.status.append('paralyz')
                tbox.addMessage(30, self.targP.name + 'is now paralyzed')
                
            elif self.effect_ID == 167:
                self.targP.statMod3+=1
                if self.targP.statMod3>6:
                    self.targP.statMod3=6
                elif self.targP.statMod3<-6:
                    self.targP.statMod3=-6
                if self.targP.statMod3>=0:
                    self.targP.SPattack_stat[0]=int(self.targP.SPattack_stat[1]*(2+self.targP.statMod3)/2)
                    tbox.addMessage(30, self.targP.name + '\'s Special Attack has been raised.')
                elif self.targP.statMod1<=0:
                    self.targP.SPattack_stat[0]=abs(int(self.targP.SPattack_stat[1]*2/(2+abs(self.targP.statMod3))))
                    tbox.addMessage(30, self.targP.name + '\'s Special Attack has been lowered.')
                self.targP.status.append('conf')
                tbox.addMessage(11, self.targP.name)
                
            elif self.effect_ID == 168:
                self.targP.status.append('burn')
                tbox.addMessage(30, self.targP.name + ' is now burnt.')
            elif self.effect_ID == 169:
                self.targP.statMod1-=2
                if self.targP.statMod1>6:
                    self.targP.statMod1=6
                elif self.targP.statMod1<-6:
                    self.targP.statMod1=-6
                if self.targP.statMod1>=0:
                    self.targP.attack_stat[0]=int(self.targP.attack_stat[1]*(2+self.targP.statMod1)/2)
                    tbox.addMessage(30, self.targP.name + '\'s Attack has been raised.')
                elif self.targP.statMod1<=0:
                    self.targP.attack_stat[0]=abs(int(self.targP.attack_stat[1]*2/(2+abs(self.targP.statMod1))))
                    tbox.addMessage(30, self.targP.name + '\'s Attack has been lowered.')
                self.targP.statMod3-=2
                if self.targP.statMod3>6:
                    self.targP.statMod3=6
                elif self.targP.statMod3<-6:
                    self.targP.statMod3=-6
                if self.targP.statMod3>=0:
                    self.targP.SPattack_stat[0]=int(self.targP.SPattack_stat[1]*(2+self.targP.statMod3)/2)
                    tbox.addMessage(30, self.targP.name + '\'s Special Attack has been raised.')
                elif self.targP.statMod1<=0:
                    self.targP.SPattack_stat[0]=abs(int(self.targP.SPattack_stat[1]*2/(2+abs(self.targP.statMod3))))
                    tbox.addMessage(30, self.targP.name + '\'s Special Attack has been lowered.')
                self.user.HP_stat[0]=0
                
            elif self.effect_ID == 183:
                self.userP.statMod1-=1
                if self.userP.statMod1>6:
                    self.userP.statMod1=6
                elif self.userP.statMod1<-6:
                    self.userP.statMod1=-6
                if self.userP.statMod1>=0:
                    self.userP.attack_stat[0]=int(self.userP.attack_stat[1]*(2+self.userP.statMod1)/2)
                    tbox.addMessage(30, self.userP.name + '\'s attack has been raised.')
                elif self.userP.statMod1<=0:
                    self.userP.attack_stat[0]=abs(int(self.userP.attack_stat[1]*2/(2+abs(self.userP.statMod1))))
                    tbox.addMessage(30, self.userP.name + '\'s attack has been lowered.')
                self.userP.statMod2-=1
                if self.userP.statMod2>6:
                    self.userP.statMod2=6
                elif self.userP.statMod2<-6:
                    self.userP.statMod2=-6
                if self.userP.statMod2>=0:
                    self.userP.defense_stat[0]=int(self.userP.defense_stat[1]*(2+self.userP.statMod2)/2)
                    tbox.addMessage(30, self.userP.name + '\'s defense has been raised.')
                elif self.userP.statMod2<=0:
                    self.userP.defense_stat[0]=abs(int(self.userP.defense_stat[1]*2/(2+abs(self.userP.statMod2))))
                    tbox.addMessage(30, self.userP.name + '\'s defense has been lowered.')
                
            elif self.effect_ID == 199:
                self.userP.HP_stat[0]-=(int(self.recoil*self.damage))
            elif self.effect_ID == 205:
                self.userP.statMod3-=2
                if self.userP.statMod3>6:
                    self.userP.statMod3=6
                elif self.userP.statMod3<-6:
                    self.userP.statMod3=-6
                if self.userP.statMod3>=0:
                    self.userP.SPattack_stat[0]=int(self.userP.SPattack_stat[1]*(2+self.userP.statMod3)/2)
                    tbox.addMessage(30, self.userP.name + '\'s Special Attack has been raised.')
                elif self.userP.statMod3<=0:
                    self.userP.SPattack_stat[0]=abs(int(self.userP.SPattack_stat[1]*2/(2+abs(self.userP.statMod3))))
                    tbox.addMessage(30, self.userP.name + '\'s Special Attack has been lowered.')
                
            elif self.effect_ID == 206:
                self.targP.statMod1-=1
                if self.targP.statMod1>6:
                    self.targP.statMod1=6
                elif self.targP.statMod1<-6:
                    self.targP.statMod1=-6
                if self.targP.statMod1>=0:
                    self.targP.attack_stat[0]=int(self.targP.attack_stat[1]*(2+self.targP.statMod1)/2)
                    tbox.addMessage(30, self.targP.name + '\'s Attack has been raised.')
                elif self.targP.statMod1<=0:
                    self.targP.attack_stat[0]=abs(int(self.targP.attack_stat[1]*2/(2+abs(self.targP.statMod1))))
                    tbox.addMessage(30, self.targP.name + '\'s Attack has been lowered.')
                self.targP.statMod2-=1
                if self.targP.statMod2>6:
                    self.targP.statMod2=6
                elif self.targP.statMod2<-6:
                    self.targP.statMod2=-6
                if self.targP.statMod2>=0:
                    self.targP.defense_stat[0]=int(self.targP.defense_stat[1]*(2+self.targP.statMod2)/2)
                    tbox.addMessage(30, self.targP.name + '\'s Defense has been raised.')
                elif self.targP.statMod2<=0:
                    self.targP.defense_stat[0]=abs(int(self.targP.defense_stat[1]*2/(2+abs(self.targP.statMod2))))
                    tbox.addMessage(30, self.targP.name + '\'s Defense has been lowered.')
                
            elif self.effect_ID == 207:
                self.userP.statMod2+=1
                if self.userP.statMod2>6:
                    self.userP.statMod2=6
                elif self.userP.statMod2<-6:
                    self.userP.statMod2=-6
                if self.userP.statMod2>=0:
                    self.userP.defense_stat[0]=int(self.userP.defense_stat[1]*(2+self.userP.statMod2)/2)
                    tbox.addMessage(30, self.userP.name + '\'s defense has been raised.')
                elif self.userP.statMod2<=0:
                    self.userP.defense_stat[0]=abs(int(self.userP.defense_stat[1]*2/(2+abs(self.userP.statMod2))))
                    tbox.addMessage(30, self.userP.name + '\'s defense has been lowered.')
                self.userP.statMod4+=1
                if self.userP.statMod4>6:
                    self.userP.statMod4=6
                elif self.userP.statMod4<-6:
                    self.userP.statMod4=-6
                if self.userP.statMod4>=0:
                    self.userP.SPdefense_stat[0]=int(self.userP.SPdefense_stat[1]*(2+self.userP.statMod4)/2)
                    tbox.addMessage(30, self.userP.name + '\'s Special Defense has been raised.')
                elif self.userP.statMod4<=0:
                    self.userP.SPdefense_stat[0]=abs(int(self.userP.SPdefense_stat[1]*2/(2+abs(self.userP.statMod4))))
                    tbox.addMessage(30, self.userP.name + '\'s Special Defense has been lowered.')
                
            elif self.effect_ID == 209:
                self.userP.statMod1+=1
                if self.userP.statMod1>6:
                    self.userP.statMod1=6
                elif self.userP.statMod1<-6:
                    self.userP.statMod1=-6
                if self.userP.statMod1>=0:
                    self.userP.attack_stat[0]=int(self.userP.attack_stat[1]*(2+self.userP.statMod1)/2)
                    tbox.addMessage(30, self.userP.name + '\'s attack has been raised.')
                elif self.userP.statMod1<=0:
                    self.userP.attack_stat[0]=abs(int(self.userP.attack_stat[1]*2/(2+abs(self.userP.statMod1))))
                    tbox.addMessage(30, self.userP.name + '\'s attack has been lowered.')
                self.userP.statMod2+=1
                if self.userP.statMod2>6:
                    self.userP.statMod2=6
                elif self.userP.statMod2<-6:
                    self.userP.statMod2=-6
                if self.userP.statMod2>=0:
                    self.userP.defense_stat[0]=int(self.userP.defense_stat[1]*(2+self.userP.statMod2)/2)
                    tbox.addMessage(30, self.userP.name + '\'s defense has been raised.')
                elif self.userP.statMod2<=0:
                    self.userP.defense_stat[0]=abs(int(self.userP.defense_stat[1]*2/(2+abs(self.userP.statMod2))))
                    tbox.addMessage(30, self.userP.name + '\'s defense has been lowered.')
                
            elif self.effect_ID == 212:
                self.userP.statMod3+=1
                if self.userP.statMod3>6:
                    self.userP.statMod3=6
                elif self.userP.statMod3<-6:
                    self.userP.statMod3=-6
                if self.userP.statMod3>=0:
                    self.userP.SPattack_stat[0]=int(self.userP.SPattack_stat[1]*(2+self.userP.statMod3)/2)
                    tbox.addMessage(30, self.userP.name + '\'s Special Attack has been raised.')
                elif self.userP.statMod3<=0:
                    self.userP.SPattack_stat[0]=abs(int(self.userP.SPattack_stat[1]*2/(2+abs(self.userP.statMod3))))
                    tbox.addMessage(30, self.userP.name + '\'s Special Attack has been lowered.')
                self.userP.statMod4+=1
                if self.userP.statMod4>6:
                    self.userP.statMod4=6
                elif self.userP.statMod4<-6:
                    self.userP.statMod4=-6
                if self.userP.statMod4>=0:
                    self.userP.SPdefense_stat[0]=int(self.userP.SPdefense_stat[1]*(2+self.userP.statMod4)/2)
                    tbox.addMessage(30, self.userP.name + '\'s Special Defense has been raised.')
                elif self.userP.statMod4<=0:
                    self.userP.SPdefense_stat[0]=abs(int(self.userP.SPdefense_stat[1]*2/(2+abs(self.userP.statMod4))))
                    tbox.addMessage(30, self.userP.name + '\'s Special Defense has been lowered.')
                
            elif self.effect_ID == 213:
                self.userP.statMod1+=1
                if self.userP.statMod1>6:
                    self.userP.statMod1=6
                elif self.userP.statMod1<-6:
                    self.userP.statMod1=-6
                if self.userP.statMod1>=0:
                    self.userP.attack_stat[0]=int(self.userP.attack_stat[1]*(2+self.userP.statMod1)/2)
                    tbox.addMessage(30, self.userP.name + '\'s attack has been raised.')
                elif self.userP.statMod1<=0:
                    self.userP.attack_stat[0]=abs(int(self.userP.attack_stat[1]*2/(2+abs(self.userP.statMod1))))
                    tbox.addMessage(30, self.userP.name + '\'s attack has been lowered.')
                self.userP.statMod5+=1
                if self.userP.statMod5>6:
                    self.userP.statMod5=6
                elif self.userP.statMod5<-6:
                    self.userP.statMod5=-6
                if self.userP.statMod5>=0:
                    self.userP.speed_stat[0]=int(self.userP.speed_stat[1]*(2+self.userP.statMod5)/2)
                    tbox.addMessage(30, self.userP.name + '\'s Speed has been raised.')
                elif self.userP.statMod5<=0:
                    self.userP.speed_stat[0]=abs(int(self.userP.speed_stat[1]*2/(2+abs(self.userP.statMod5))))
                    tbox.addMessage(30, self.userP.name + '\'s Speed has been lowered.')
                
            elif self.effect_ID == 215:
                self.userP.HP_stat[0] += (self.userP.HP_stat[1]//2)
                
            elif self.effect_ID == 219:
                self.userP.statMod5-=1
                if self.userP.statMod5>6:
                    self.userP.statMod5=6
                elif self.userP.statMod5<-6:
                    self.userP.statMod5=-6
                if self.userP.statMod5>=0:
                    self.userP.speed_stat[0]=int(self.userP.speed_stat[1]*(2+self.userP.statMod5)/2)
                    tbox.addMessage(30, self.userP.name + '\'s Speed has been raised.')
                elif self.userP.statMod5<=0:
                    self.userP.speed_stat[0]=abs(int(self.userP.speed_stat[1]*2/(2+abs(self.userP.statMod5))))
                    tbox.addMessage(30, self.userP.name + '\'s Speed has been lowered.')
                 
            elif self.effect_ID == 230:
                self.userP.statMod2-=1
                if self.userP.statMod2>6:
                    self.userP.statMod2=6
                elif self.userP.statMod2<-6:
                    self.userP.statMod2=-6
                if self.userP.statMod2>=0:
                    self.userP.defense_stat[0]=int(self.userP.defense_stat[1]*(2+self.userP.statMod2)/2)
                    tbox.addMessage(30, self.userP.name + '\'s defense has been raised.')
                elif self.userP.statMod2<=0:
                    self.userP.defense_stat[0]=abs(int(self.userP.defense_stat[1]*2/(2+abs(self.userP.statMod2))))
                    tbox.addMessage(30, self.userP.name + '\'s defense has been lowered.')
                self.userP.statMod4-=1
                if self.userP.statMod4>6:
                    self.userP.statMod4=6
                elif self.userP.statMod4<-6:
                    self.userP.statMod4=-6
                if self.userP.statMod4>=0:
                    self.userP.SPdefense_stat[0]=int(self.userP.SPdefense_stat[1]*(2+self.userP.statMod4)/2)
                    tbox.addMessage(30, self.userP.name + '\'s Special Defense has been raised.')
                elif self.userP.statMod4<=0:
                    self.userP.SPdefense_stat[0]=abs(int(self.userP.SPdefense_stat[1]*2/(2+abs(self.userP.statMod4))))
                    tbox.addMessage(30, self.userP.name + '\'s Special Defense has been lowered.')
                
            elif self.effect_ID == 254:
                self.userP.HP_stat[0]-=(int(self.recoil*self.damage))
                randomburn = random.randrange(1,101)
                if randomburn <= 10:
                    self.targP.status.append('burn')
                
            elif self.effect_ID == 263:
                self.userP.HP_stat[0]-=(int(self.recoil*self.damage))
                randompara = random.randrange(1, 101)
                if randompara <= 10:
                    self.targP.status.append('paralyz')
            elif self.effect_ID == 270:
                self.userP.HP_stat[0]-=(int(self.recoil*self.damage))
                
            elif self.effect_ID == 291:
                self.userP.statMod3+=1
                if self.userP.statMod3>6:
                    self.userP.statMod3=6
                elif self.userP.statMod3<-6:
                    self.userP.statMod3=-6
                if self.userP.statMod3>=0:
                    self.userP.SPattack_stat[0]=int(self.userP.SPattack_stat[1]*(2+self.userP.statMod3)/2)
                    tbox.addMessage(30, self.userP.name + '\'s Special Attack has been raised.')
                elif self.userP.statMod3<=0:
                    self.userP.SPattack_stat[0]=abs(int(self.userP.SPattack_stat[1]*2/(2+abs(self.userP.statMod3))))
                    tbox.addMessage(30, self.userP.name + '\'s Special Attack has been lowered.')
                self.userP.statMod4+=1
                if self.userP.statMod4>6:
                    self.userP.statMod4=6
                elif self.userP.statMod4<-6:
                    self.userP.statMod4=-6
                if self.userP.statMod4>=0:
                    self.userP.SPdefense_stat[0]=int(self.userP.SPdefense_stat[1]*(2+self.userP.statMod4)/2)
                    tbox.addMessage(30, self.userP.name + '\'s Special Defense has been raised.')
                elif self.userP.statMod4<=0:
                    self.userP.SPdefense_stat[0]=abs(int(self.userP.SPdefense_stat[1]*2/(2+abs(self.userP.statMod4))))
                    tbox.addMessage(30, self.userP.name + '\'s Special Defense has been lowered.')
                self.userP.statMod5+=1
                if self.userP.statMod5>6:
                    self.userP.statMod5=6
                elif self.userP.statMod5<-6:
                    self.userP.statMod5=-6
                if self.userP.statMod5>=0:
                    self.userP.speed_stat[0]=int(self.userP.speed_stat[1]*(2+self.userP.statMod5)/2)
                    tbox.addMessage(30, self.userP.name + '\'s Speed has been raised.')
                elif self.userP.statMod5<=0:
                    self.userP.speed_stat[0]=abs(int(self.userP.speed_stat[1]*2/(2+abs(self.userP.statMod5))))
                    tbox.addMessage(30, self.userP.name + '\'s Speed has been lowered.')
                
            elif self.effect_ID == 296:
                self.userP.statMod5+=1
                if self.userP.statMod5>6:
                    self.userP.statMod5=6
                elif self.userP.statMod5<-6:
                    self.userP.statMod5=-6
                if self.userP.statMod5>=0:
                    self.userP.speed_stat[0]=int(self.userP.speed_stat[1]*(2+self.userP.statMod5)/2)
                    tbox.addMessage(30, self.userP.name + '\'s Speed has been raised.')
                elif self.userP.statMod5<=0:
                    self.userP.speed_stat[0]=abs(int(self.userP.speed_stat[1]*2/(2+abs(self.userP.statMod5))))
                    tbox.addMessage(30, self.userP.name + '\'s Speed has been lowered.')
                
            elif self.effect_ID == 297:
                self.targP.statMod4-=2
                if self.targP.statMod4>6:
                    self.targP.statMod4=6
                elif self.targP.statMod4<-6:
                    self.targP.statMod4=-6
                if self.targP.statMod4>=0:
                    self.targP.SPdefense_stat[0]=int(self.targP.SPdefense_stat[1]*(2+self.targP.statMod4)/2)
                    tbox.addMessage(30, self.targP.name + '\'s Special Defense has been raised.')
                elif self.targP.statMod4<=0:
                    self.targP.SPdefense_stat[0]=abs(int(self.targP.SPdefense_stat[1]*2/(2+abs(self.targP.statMod4))))
                    tbox.addMessage(30, self.targP.name + '\'s Special Defense has been lowered.')
                
            elif self.effect_ID == 309:
                self.userP.statMod1+=2
                if self.userP.statMod1>6:
                    self.userP.statMod1=6
                elif self.userP.statMod1<-6:
                    self.userP.statMod1=-6    
                if self.userP.statMod1>=0:
                    self.userP.attack_stat[0]=int(self.userP.attack_stat[1]*(2+self.userP.statMod1)/2)
                    tbox.addMessage(30, self.userP.name + '\'s attack has been raised.')
                elif self.userP.statMod1<=0:
                    self.userP.attack_stat[0]=abs(int(self.userP.attack_stat[1]*2/(2+abs(self.userP.statMod1))))
                    tbox.addMessage(30, self.userP.name + '\'s attack has been lowered.')
                self.userP.statMod3+=2
                if self.userP.statMod3>6:
                    self.userP.statMod3=6
                elif self.userP.statMod3<-6:
                    self.userP.statMod3=-6
                if self.userP.statMod3>=0:
                    self.userP.SPattack_stat[0]=int(self.userP.SPattack_stat[1]*(2+self.userP.statMod3)/2)
                    tbox.addMessage(30, self.userP.name + '\'s Special Attack has been raised.')
                elif self.userP.statMod3<=0:
                    self.userP.SPattack_stat[0]=abs(int(self.userP.SPattack_stat[1]*2/(2+abs(self.userP.statMod3))))
                    tbox.addMessage(30, self.userP.name + '\'s Special Attack has been lowered.')
                self.userP.statMod5+=2
                if self.userP.statMod5>6:
                    self.userP.statMod5=6
                elif self.userP.statMod5<-6:
                    self.userP.statMod5=-6
                if self.userP.statMod5>=0:
                    self.userP.speed_stat[0]=int(self.userP.speed_stat[1]*(2+self.userP.statMod5)/2)
                    tbox.addMessage(30, self.userP.name + '\'s Speed has been raised.')
                elif self.userP.statMod5<=0:
                    self.userP.speed_stat[0]=abs(int(self.userP.speed_stat[1]*2/(2+abs(self.userP.statMod5))))
                    tbox.addMessage(30, self.userP.name + '\'s Speed has been lowered.')
                self.userP.statMod2-=1
                if self.userP.statMod2>6:
                    self.userP.statMod2=6
                elif self.userP.statMod2<-6:
                    self.userP.statMod2=-6
                if self.userP.statMod2>=0:
                    self.userP.defense_stat[0]=int(self.userP.defense_stat[1]*(2+self.userP.statMod2)/2)
                    tbox.addMessage(30, self.userP.name + '\'s defense has been raised.')
                elif self.userP.statMod2<=0:
                    self.userP.defense_stat[0]=abs(int(self.userP.defense_stat[1]*2/(2+abs(self.userP.statMod2))))
                    tbox.addMessage(30, self.userP.name + '\'s defense has been lowered.')
                self.userP.statMod4-=1
                if self.userP.statMod4>6:
                    self.userP.statMod4=6
                elif self.userP.statMod4<-6:
                    self.userP.statMod4=-6
                if self.userP.statMod4>=0:
                    self.userP.SPdefense_stat[0]=int(self.userP.SPdefense_stat[1]*(2+self.userP.statMod4)/2)
                    tbox.addMessage(30, self.userP.name + '\'s Special Defense has been raised.')
                elif self.userP.statMod4<=0:
                    self.userP.SPdefense_stat[0]=abs(int(self.userP.SPdefense_stat[1]*2/(2+abs(self.userP.statMod4))))
                    tbox.addMessage(30, self.userP.name + '\'s Special Defense has been lowered.')
                
            elif self.effect_ID == 313:
                self.userP.statMod1+=1
                if self.userP.statMod1>6:
                    self.userP.statMod1=6
                elif self.userP.statMod1<-6:
                    self.userP.statMod1=-6
                if self.userP.statMod1>=0:
                    self.userP.attack_stat[0]=int(self.userP.attack_stat[1]*(2+self.userP.statMod1)/2)
                    tbox.addMessage(30, self.userP.name + '\'s attack has been raised.')
                elif self.userP.statMod1<=0:
                    self.userP.attack_stat[0]=abs(int(self.userP.attack_stat[1]*2/(2+abs(self.userP.statMod1))))
                    tbox.addMessage(30, self.userP.name + '\'s attack has been lowered.')
                self.userP.statMod5+=2
                if self.userP.statMod5>6:
                    self.userP.statMod5=6
                elif self.userP.statMod5<-6:
                    self.userP.statMod5=-6
                if self.userP.statMod5>=0:
                    self.userP.speed_stat[0]=int(self.userP.speed_stat[1]*(2+self.userP.statMod5)/2)
                    tbox.addMessage(30, self.userP.name + '\'s Speed has been raised.')
                elif self.userP.statMod5<=0:
                    self.userP.speed_stat[0]=abs(int(self.userP.speed_stat[1]*2/(2+abs(self.userP.statMod5))))
                    tbox.addMessage(30, self.userP.name + '\'s Speed has been lowered.')
                
            elif self.effect_ID == 322:
                self.userP.statMod3+=3
                if self.userP.statMod3>6:
                    self.userP.statMod3=6
                elif self.userP.statMod3<-6:
                    self.userP.statMod3=-6
                if self.userP.statMod3>=0:
                    self.userP.SPattack_stat[0]=int(self.userP.SPattack_stat[1]*(2+self.userP.statMod3)/2)
                    tbox.addMessage(30, self.userP.name + '\'s Special Attack has been raised.')
                elif self.userP.statMod3<=0:
                    self.userP.SPattack_stat[0]=abs(int(self.userP.SPattack_stat[1]*2/(2+abs(self.userP.statMod3))))
                    tbox.addMessage(30, self.userP.name + '\'s Special Attack has been lowered.')
                
            elif self.effect_ID == 328:
                self.userP.statMod1+=1
                if self.userP.statMod1>6:
                    self.userP.statMod1=6
                elif self.userP.statMod1<-6:
                    self.userP.statMod1=-6
                if self.userP.statMod1>=0:
                    self.userP.attack_stat[0]=int(self.userP.attack_stat[1]*(2+self.userP.statMod1)/2)
                    tbox.addMessage(30, self.userP.name + '\'s attack has been raised.')
                elif self.userP.statMod1<=0:
                    self.userP.attack_stat[0]=abs(int(self.userP.attack_stat[1]*2/(2+abs(self.userP.statMod1))))
                    tbox.addMessage(30, self.userP.name + '\'s attack has been lowered.')
                self.userP.statMod3+=1
                if self.userP.statMod3>6:
                    self.userP.statMod3=6
                elif self.userP.statMod3<-6:
                    self.userP.statMod3=-6
                if self.userP.statMod3>=0:
                    self.userP.SPattack_stat[0]=int(self.userP.SPattack_stat[1]*(2+self.userP.statMod3)/2)
                    tbox.addMessage(30, self.userP.name + '\'s Special Attack has been raised.')
                elif self.userP.statMod3<=0:
                    self.userP.SPattack_stat[0]=abs(int(self.userP.SPattack_stat[1]*2/(2+abs(self.userP.statMod3))))
                    tbox.addMessage(30, self.userP.name + '\'s Special Attack has been lowered.')
                
            elif self.effect_ID == 329:
                self.userP.statMod2+=3
                if self.userP.statMod2>6:
                    self.userP.statMod2=6
                elif self.userP.statMod2<-6:
                    self.userP.statMod2=-6
                if self.userP.statMod2>=0:
                    self.userP.defense_stat[0]=int(self.userP.defense_stat[1]*(2+self.userP.statMod2)/2)
                    tbox.addMessage(30, self.userP.name + '\'s defense has been raised.')
                elif self.userP.statMod2<=0:
                    self.userP.defense_stat[0]=abs(int(self.userP.defense_stat[1]*2/(2+abs(self.userP.statMod2))))
                    tbox.addMessage(30, self.userP.name + '\'s defense has been lowered.')
                
            elif self.effect_ID == 331:
                self.targP.statMod5-=1
                if self.targP.statMod5>6:
                    self.targP.statMod5=6
                elif self.targP.statMod5<-6:
                    self.targP.statMod5=-6
                if self.targP.statMod5>=0:
                    self.targP.speed_stat[0]=int(self.targP.speed_stat[1]*(2+self.targP.statMod5)/2)
                    tbox.addMessage(30, self.targP.name + '\'s Speed has been raised.')
                elif self.targP.statMod5<=0:
                    self.targP.speed_stat[0]=abs(int(self.targP.speed_stat[1]*2/(2+abs(self.targP.statMod5))))
                    tbox.addMessage(30, self.targP.name + '\'s Speed has been lowered.')
                
            elif self.effect_ID == 335:
                self.userP.statMod2-=1
                if self.userP.statMod2>6:
                    self.userP.statMod2=6
                elif self.userP.statMod2<-6:
                    self.userP.statMod2=-6
                if self.userP.statMod2>=0:
                    self.userP.defense_stat[0]=int(self.userP.defense_stat[1]*(2+self.userP.statMod2)/2)
                    tbox.addMessage(30, self.userP.name + '\'s defense has been raised.')
                elif self.userP.statMod2<=0:
                    self.userP.defense_stat[0]=abs(int(self.userP.defense_stat[1]*2/(2+abs(self.userP.statMod2))))
                    tbox.addMessage(30, self.userP.name + '\'s defense has been lowered.')
                self.userP.statMod4-=1
                if self.userP.statMod4>6:
                    self.userP.statMod4=6
                elif self.userP.statMod4<-6:
                    self.userP.statMod4=-6
                if self.userP.statMod4>=0:
                    self.userP.SPdefense_stat[0]=int(self.userP.SPdefense_stat[1]*(2+self.userP.statMod4)/2)
                    tbox.addMessage(30, self.userP.name + '\'s Special Defense has been raised.')
                elif self.userP.statMod4<=0:
                    self.userP.SPdefense_stat[0]=abs(int(self.userP.SPdefense_stat[1]*2/(2+abs(self.userP.statMod4))))
                    tbox.addMessage(30, self.userP.name + '\'s Special Defense has been lowered.')
                self.userP.statMod5-=1
                if self.userP.statMod5>6:
                    self.userP.statMod5=6
                elif self.userP.statMod5<-6:
                    self.userP.statMod5=-6
                if self.userP.statMod5>=0:
                    self.userP.speed_stat[0]=int(self.userP.speed_stat[1]*(2+self.userP.statMod5)/2)
                    tbox.addMessage(30, self.userP.name + '\'s Speed has been raised.')
                elif self.userP.statMod5<=0:
                    self.userP.speed_stat[0]=abs(int(self.userP.speed_stat[1]*2/(2+abs(self.userP.statMod5))))
                    tbox.addMessage(30, self.userP.name + '\'s Speed has been lowered.')
            else:
                pass
#####################################end effects###################################################################################
        #deal damage
        self.targP.HP_stat[0] -= self.damage
        if self.userP.HP_stat[0] > self.userP.HP_stat[1]:
            self.userP.HP_stat[0] = self.userP.HP_stat[1]
        if self.targP.HP_stat[0] <= 0:
            self.targP.HP_stat[0] = 0
        print(str(self.targP.HP_stat[0])+ '/'+ str(self.targP.HP_stat[1]))
        return
        
    def do_damage (self):
        self.damage = 0
        if self.damage_type == 'physical':
            self.damage = int(((((2 * self.user.pokemon[self.user.activePoke].level / 5 + 2) * self.user.pokemon[self.user.activePoke].attack_stat[0] * self.power / self.target.pokemon[self.target.activePoke].defense_stat[0]) / 50) + 2) * self.type_check * self.type_check2 * random.randrange(85, 101) / 100)
        elif self.damage_type == 'special':                                                                                                                                                         
            self.damage = int(((((2 * self.user.pokemon[self.user.activePoke].level / 5 + 2) * self.user.pokemon[self.user.activePoke].SPattack_stat[0] * self.power / self.target.pokemon[self.target.activePoke].SPdefense_stat[0]) / 50) + 2) * self.type_check * self.type_check2 * random.randrange(85, 101) / 100)
        else:
            self.damage = 0
        return
    
class Accuracy:
    
    def __init__ (self):
        self.check
        
    def check (self, ACC = 100):
        self.ACC = ACC
        randomnumber=random.randrange(1, 101)
        if ACC == -1:
            return True
        elif randomnumber in range (0, ACC + 1):
            return True
        else:
            return False
        